package svlt;

import java.io.IOException;
import java.sql.Date;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Controlador.ODV;
import dominioVO.ClienteVO;

/**
 * Servlet implementation class altaCliente
 */
@WebServlet("/altaCliente")
public class altaCliente extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public altaCliente() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		ClienteVO cliente = new ClienteVO(
				request.getParameter("cuit"),
				request.getParameter("razonSocial"),
				Date.valueOf("2014-06-07"),		
				Float.valueOf(request.getParameter("descuentos")),
				Boolean.valueOf(request.getParameter("respInscripto")),
				Float.valueOf(request.getParameter("ingBrutos")),
				Integer.valueOf(request.getParameter("condPago")),
				Boolean.valueOf(request.getParameter("estado"))
			);
			
			ODV.getInstancia().altaCliente(cliente);
			
			/*
		    request.setAttribute("Cliente", cliente);
		    
		    RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/MostrarCliente.jsp");
		   dispatcher.forward(request, response);
		   */
			RequestDispatcher dispatcher = request.getRequestDispatcher("ODV.html");
			dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
